home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / 3dkit1.zip / 3DKIT.DOC < prev    next >
Text File  |  1992-06-29  |  28KB  |  595 lines

  1.                 TOOLS FOR 3-D WIREFRAME GRAPHICS
  2.           ================================
  3.  
  4.                     May 1992
  5.  
  6. Hi!  I have been amazed by the good reception to my 3dv wireframe viewer
  7. and by all the e-mail that it generated.  My ego was sufficiently massaged
  8. to motivate me in producing a few tools for playing around with 3-D
  9. wireframe objects.  These can be used in conjunction with 3dv, or on their
  10. own.
  11.  
  12. 3dv allows you to display 3-D objects on a PC screen, and rotate them in
  13. real-time by moving the mouse.  It can be found, for example, in the
  14. <MSDOS.GRAPHICS> directory of SIMTEL20, and in lots of other places.  Look
  15. for 3DV25.ZIP (or .ZOO, etc).  It is FREE, and so are the goodies contained
  16. here.
  17.  
  18. Digression --  For convenience, I give here the location of free and
  19. shareware software in SIMTEL20.  See SIMTEL.DOC for info on how to get it.
  20. Note that often new software versions are uploaded with slightly different
  21. names; if you don't find a file try a directory listing.  There are many
  22. other archive sites in the Internet, accessible through FTP and some
  23. through e-mail servers.  For example, garbo.uwasa.fi, in Finland (e-mail
  24. access instructions available by sending a 'send help' message, or a null
  25. message, to mailserv@garbo.uwasa.fi with a subject line of
  26. 'garbo-request'.  Don't include the quotes '').  Much software is also
  27. available from bulletin boards.  -- End of digression.
  28.  
  29. 3dv uses a simple plain text file format, let's call it 3DV format, that I
  30. am taking as a common format for 3-D wireframe objects (objects formed by
  31. points and lines in three dimensions).  One of the programs, 3DVto2D, does
  32. a perspective projection, like those displayed by 3dv, but with output to a
  33. file that can later be plotted, printed, or whatever.  This output is an
  34. ASCII list of 2-D points (a "2D list"), that will be our common format for
  35. 2-D pictures.  The idea is to have other tools that manipulate these files
  36. or convert between these and other formats, a bit like what PBMPLUS does
  37. for rasters.  I have written a few of these tools, included here with C
  38. sources, to get the ball rolling.  I hope that others may take over. 
  39. Incidentally, the code in 3DVto2D may interest those who have asked, mostly
  40. politely (funny the attitudes of some people), for source or hints on 3-D
  41. transformations (I am not releasing the 3dv source for reasons explained in
  42. the documentation of that package).
  43.  
  44. The main components of this kit are:
  45.  
  46. OFFto3DV  -  Converts from a format called OFF (Object File Format) to 3DV.
  47. There are lots of nice 3-D objects in OFF format around the Internet. There
  48. are also around programs to convert from other formats into OFF.  See
  49. OBJECTS.DOC for more info on where to find them.
  50.  
  51. SHDto3DV  -  Converts from "shaded" format to 3DV.
  52.  
  53. XYZto3DV  -  XYZ is an interactive 3-D editor/builder written by Dale P.
  54. Stocker to create objects for the SurfaceModel, Automove, and DKB raytracer
  55. packages.  XYZto3DV (you gessed it!) converts XYZ output to 3DV format.
  56.  
  57. 3DHELP  -  A C program written by Bruce Colletti to create 3DV files from
  58. mathematical functions.  Source only, since you have to code and link your
  59. function.  See 3DHELP.C for documentation.
  60.  
  61. 3DMERGE  -  Combines two 3DV files into one.
  62.  
  63. SHRINK  -  Minimizes the size of 3DV files.  Facilitates converting objects
  64. to 3DV format; you can use a straightforward and simple-minded approach and
  65. let SHRINK to take care of efficiency.
  66.  
  67. 3DVto2D  -  Projects a 3-D object in 3DV format into a plane, from a
  68. user-specified viewpoint.  The output (2D list) can be directly
  69. displayed/printed by GNUPLOT, a free scientific graphing program (good).
  70.  
  71. 2DtoHPGL  -  Converts a 2D list to HPGL plotter instructions.  There are
  72. utilities for printing HPGL on a variety of printers, and to convert it to
  73. AutoCAD format, for example.
  74.  
  75. 2DtoEXF  -  Converts 2D list to Evolution Computing's EXF format for
  76. EasyCAD (and presumably FastCAD).  You can then use the CAD program to
  77. modify the drawing to your heart's content.
  78.  
  79. The executables, for MSDOS, were compiled with Turbo C 2.0 using the
  80. compact memory model.
  81.  
  82. There are also some 3-D object files (see ART.DOC), and a few example
  83. GNUPLOT scripts and DOS batch files.
  84.  
  85.  
  86.                   3DV FILE FORMAT
  87.                   ---------------
  88.  
  89. It is a plain ASCII text file that contains a list of point coordinates,
  90. followed by a list of move/draw instructions defining the lines in the
  91. object.  It looks like this:
  92.  
  93. number_of_points
  94. x1 y1 z1
  95. x2 y2 z2
  96. ...
  97. xn yn zn
  98. number_of_move-draws
  99. p1 c1
  100. p2 c2
  101. ...
  102. pm cm
  103.  
  104. The xi, yi, zi are the coordinates of each point, one set to a line,
  105. separated by spaces.  Each pair (pj cj) means "draw a line to point number
  106. pj using colour number cj".  The point numbers are the indices (origin 1)
  107. of the points in the list of coordinates (e.g. "5" is the 5-th point in the
  108. list).  The colour numbers are the usual IBM PC colour indices 1 to 15.  A
  109. zero colour means "move" to the point without drawing (or drawing in the
  110. background colour, if you prefer).  Multiple spaces do not matter.
  111. Coordinate values can take any form accepted by C as a floating point
  112. number, and the rest must be integers.  See the included *.3DV files for
  113. examples.
  114.  
  115. Actually, 3dv and some of the tools do not care about line feeds and
  116. carriage returns.  However, some processing (e.g. in 3DMERGE) is easier if
  117. we always have one item per line, so let's stick to that.
  118.  
  119. In retrospect, it might have been a good idea to allow for comments
  120. embedded in the file, but now it is too late.  We can add anything at the
  121. end of the file, though.  I suggest including there object descriptions and
  122. credits.
  123.  
  124. This format is fairly compact and convenient.  It is fine for wireframe
  125. objects, but of course it does not include the topological information
  126. about faces, etc., that would be needed for hidden line elimination, solid
  127. modelling, or other uses.
  128.  
  129.  
  130.                    2D LIST FORMAT
  131.                    --------------
  132.  
  133. This is the output from 3DVto2D, and I propose it as a common format for
  134. two-dimensional drawings.  It is simply one or more comment lines beginning
  135. with #, followed by a list of coordinate pairs and colour information, with
  136. implicit "draw" instructions and "moves" indicated by a blank line as well
  137. as a colour equal to zero:
  138.  
  139. # ... x_range=[xmin:xmax] ... y_range=[ymin:ymax] ...
  140. #... 
  141.  
  142. xa ya ca
  143. xb yb cb
  144. ...
  145. xc yc cc
  146.  
  147. xd yd cd
  148. xe ye ce
  149. ...
  150. ...
  151. xt yt ct
  152.  
  153. xu yu cu
  154. xv yv cv
  155. ...
  156. xw yw cw
  157.  
  158. The x and y are the coordinate values (integers or reals), and the c are
  159. colours (0 to 15).  A zero colour indicates a move, and must follow a blank
  160. line; in the example, ca, cd, and cu must be zero.  At least for use in
  161. 2DtoHPGL without the /s option, somewhere in the first line (comment) we
  162. must have the keywords x_range and y_range followed by bounds for the x and
  163. y values in the format shown above (see the description of 3DVto2D, below,
  164. for an example).  There is no compulsory line count; the data ends with the
  165. end of file.  For examples see the output generated by 3DVto2D.
  166.  
  167. These files are compatible with the GNUPLOT graphing program, which can be
  168. used with its default input parameters to display or print the drawing
  169. (GNUPLOT will just ignore the third column containing the colours).
  170. GNUPLOT is free and you can find it, for example, in SIMTEL20 as
  171. <MSDOS.PLOT>GNUPLT32.ZIP .
  172.  
  173.  
  174.                 THE TOOLS IN DETAIL
  175.                 -------------------
  176.  
  177. Unless stated otherwise, if the names of the files to be processed are not
  178. given on the command line then the standard input/output streams are used. 
  179. Thus, these tools can be used as filters, with DOS pipes or redirection. 
  180. For a simple example see Xto3.BAT .
  181.  
  182. Some of the tools accept optional command switches.  These can go in any
  183. order, before the file names, if any.  Forms different from those shown
  184. here might also work, I am not sure of the exact requirements of the public
  185. domain getopt.c that I used.  In particular, you could use - as a switch
  186. character instead of /, although you might run into trouble with minus
  187. signs.  Try it at your own risk.
  188.  
  189. Much of this could probably have been done more elegantly (?) with AWK or
  190. SED scripts.  With C, however, the tools are fast and self-contained.  I
  191. wrote the code aiming at clarity ahead of efficiency.  For example, I used
  192. mostly indexed arrays, instead of trying to be too clever with pointers.
  193.  
  194. In the syntax, below, brackets indicate optional items.  You get a similar
  195. help message by running the program with /? or other invalid arguments.
  196.  
  197.  
  198.                   OFFto3DV
  199.  
  200. Syntax:  OFFto3DV [/cn] [infile [outfile]]
  201.  
  202. Converts infile, in OFF ASCII Indexed_Poly format, into outfile, in 3DV
  203. format.  The option /cn specifies n as the colour to be used; the default
  204. is /c9.
  205.  
  206. The conversion is simple-minded.  Run the output through SHRINK to reduce
  207. the file size.
  208.  
  209. OFF (Object File Format) objects may be specified with a set of several
  210. files.  The Indexed_Poly "geometry" file, used by OFFto3DV, seems to be
  211. (almost?) always present.  The convention is to use a file extension
  212. ".geom" for this, on machines that support long file extension names. Often
  213. there is also a file with extension ".aoff", that contains object
  214. information such as author, description, and copyright.  There may be other
  215. files with data on colours, polygon normals, etc., which are ignored here.
  216.  
  217. These objects (or at least most of them) are formed by polygons.  The
  218. Indexed_Poly file is somewhat similar to a 3DV file, with a list of vertex
  219. coordinates followed by a list of polygons.  The first line has three
  220. integers: the number of vertices, the number of polygons, and the total
  221. number of edges.  Then comes the list of vertex coordinates, triples of
  222. floating point numbers.  The polygons immediately follow, one per line. 
  223. These are specified by a list of integers, where the first is the number of
  224. polygon vertices, and the others are the vertex indices in the coordinates
  225. list.
  226.  
  227. See OBJECTS.DOC for sources of OFF objects, and of the full format
  228. specification if you really want it.
  229.  
  230.  
  231.                   SHDto3DV
  232.  
  233. Syntax:  SHDto3DV [/cn] [infile [outfile]]
  234.  
  235. Converts infile, in another common object format, explained below, into
  236. outfile, in 3DV format.  The option /cn specifies n as the colour to be
  237. used; the default is /c9.
  238.  
  239. The conversion is simple-minded.  Run the output through SHRINK to reduce
  240. the file size.
  241.  
  242. I found a number of objects in this format on the Internet, for example in
  243. hanauma.stanford.edu pub/graphics/Comp.graphics/objects/3d.  Initially I
  244. thought that this was OFF, and wrote this converter.  It turned out that
  245. this is slightly different.  In hanauma.stanford.edu
  246. pub/graphics/Comp.graphics there is a file with the famous Sutherland
  247. VolksWagen, where it is called "shaded" format, being used in a display
  248. program called "shaded" running on SUN hardware.  The file contains AWK
  249. scripts to convert the original VW data from a similar but more verbose
  250. format into "shaded", and also the following note:
  251.  
  252.     The format for the "shaded" data files appears to be
  253.  
  254.     no_of_points    no_of_polygons
  255.     minx maxy minz  maxx miny maxz
  256.     x1 y1 z1
  257.     x2 y2 z2
  258.     ...
  259.     xnp ynp znp
  260.     no_of_corners point1 point2 point3 ... pointnc
  261.     ...
  262.     no_of_corners point1 point2 ... pointnc
  263.  
  264.     The point numbers are implicit, i.e. "5" refers to the fifth
  265.     point in the list. See the file "socbal.dat" for an example.
  266.  
  267. This is the same as OFF, except for the extra second line with the ranges,
  268. that we ignore, and the lack of an edges count, which forces reading all
  269. the polygons in before starting to write the move/draw instructions.
  270.  
  271.  
  272.                   XYZto3DV
  273.  
  274. Syntax:  XYZto3DV [infile [outfile]]
  275.  
  276. XYZ2 is an interactive 3-D editor/builder written by Dale P. Stocker to
  277. create objects for the SurfaceModel, Automove, and DKB raytracer packages. 
  278. XYZto3DV converts the *.3DL file produced by XYZ2 into a 3DV file.  The
  279. *.3DP and *.3DS files are not needed.
  280.  
  281. The conversion is simple-minded.  Run the output through SHRINK to reduce
  282. the file size.
  283.  
  284. XYZ2 is free and can be found, for example, in SIMTEL20 as
  285. <MSDOS.SURFMODL>XYZ21.ZIP .
  286.  
  287. Other 3-D editors that might be useful for designing objects are 3DMOD
  288. (free, I found it somewhere in the Internet), and NORTHCAD (shareware,
  289. <MSDOS.CAD>NCAD3D42.ZIP in SIMTEL20).  However, they do not include
  290. documentation on their file formats.  3DMOD is (C) 1991 by Micah Silverman,
  291. 25 Pierrepoint Ave., Postdam, New York 13676, tel. 315-265-7140.
  292.  
  293.  
  294.                   3DMERGE
  295.  
  296. Syntax:  3DMERGE infile1 [infile2 [outfile]]
  297.  
  298. Combines two 3DV files (infile1 and infile2) into one (outfile).  Note that
  299. at least one input file is required in the command line.
  300.  
  301. The merging is simple-minded.  Run the output through SHRINK to reduce the
  302. file size.
  303.  
  304. I wrote this mainly to put together the parts of the Sutherland VW from
  305. hanauma (see above in SHDto3DV).  That was a waste of time, because there
  306. was a full VW in "shaded" format somewhere else in hanauma, and in OFF
  307. format in other places.  It might have other uses, though.  BTW, there is
  308. an interesting photo in IEEE Computer Graphics & Applications, January
  309. 1987, p.8, showing Ivan Sutherland students digitizing the VW in 1971 using
  310. paint, measuring tape, and rulers.
  311.  
  312.  
  313.                    SHRINK
  314.  
  315. Syntax:  SHRINK [/on] [/tx] [/q] [infile [outfile]]
  316.  
  317. This is by far the most complex program of the lot.  It attempts to reduce
  318. the size of a 3DV file in three steps:
  319.  
  320. 1. Checks for (nearly) duplicated points.  Two points are considered the
  321. same, and one of them dropped, if the absolute differences in all the three
  322. coordinates are smaller than certain tolerance.  The tolerance is
  323. calculated as the maximum coordinate range divided by x, where x is given
  324. in the /t option.  The default is /t1e6.  Confused?  Forget it, just use
  325. the default!
  326.  
  327. 2. Checks for duplicated lines, including those resulting from deleting
  328. (actually merging) points in step 1.  If two lines joining the same two
  329. points have different colours, the colours are ORed.
  330.  
  331. 3. Rearranges the move/draw instructions to eliminate as many moves as
  332. possible.  This is a highly convoluted pointer chasing exercise, and I wont
  333. try to explain how it works.  You may be able to follow the code, it is
  334. reasonably well commented.
  335.  
  336. With the /o option you can restrict SHRINK to use only step 1 (/o1), 1 and
  337. 2 (/o2), or all three steps (/o3, the default).  Don't ask me why.  In any
  338. case "obviously" redundant moves are omitted.
  339.  
  340. SHRINK can take a while on large files, so by default it outputs progress
  341. messages to the standard error stream (usually the screen).  You can
  342. suppress the messages with the /q (quiet) option.
  343.  
  344. This tool simplifies the writing of object generation, conversion, or
  345. manipulation procedures.  Just do it the easy way, and let SHRINK take care
  346. of the efficiency aspects.
  347.  
  348.  
  349.                   3DVto2D
  350.  
  351. Syntax:  3DVto2D [/tx] [/nx] [/dx] [infile [outfile]]
  352.  
  353. Now, here is the answer to all those who asked for examples of code for 3-D
  354. transformations!  It is also useful for high resolution display and
  355. hard-copy.  Projects in perspective a 3-D object in 3DV format into a plane,
  356. from a user-specified viewpoint.
  357.  
  358. To understand the specification of the viewpoint, think of the object as
  359. enclosed by a box, and located at the centre of a sphere.  The box is just
  360. large enough to contain the object, with sides parallel to the coordinate
  361. axes.  The x axis goes from left to right, y from back to front, and z goes
  362. up.  The box centre is at the centre of the sphere.  The viewpoint can be
  363. anywhere on the sphere surface.  Its location is specified by latitude and
  364. longitude in degrees, as on the surface of the Earth.  Latitude goes from
  365. -90 at the South Pole, through 0 on the Equator, to 90 at the North Pole. 
  366. Zero longitude is at the front, increasing to the right; you can use any
  367. positive or negative number which is interpreted modulo 360, i.e., plus or
  368. minus 360 degrees brings you back to the front of the sphere.
  369.  
  370. This is the same system used in 3dv, where you move around the object by
  371. changing longitude with left-right mouse movements, and latitude by moving
  372. up-down.  You can use 3dv to choose a good viewpoint, noting the displayed
  373. latitude/longitude values.  The /t option specifies the viewpoint laTitude,
  374. and /n the loNgitude.  The defaults are zero.  For example,
  375.  
  376.     3DVto2D /t33.3 /n-60 thingy.3dv thingy.2d
  377.  
  378. would produce a view from a point at latitude 33.3 degrees (North) and
  379. longitude -60 degrees (60 degrees West).
  380.  
  381. The /d option can be used to give the viewpoint distance, i.e. the sphere
  382. radius.  A positive value is an absolute distance in user units, that is,
  383. in the same units used for the points coordinates.  A /d0 is equivalent to
  384. an infinite distance or, in other words, produces an orthogonal projection
  385. (no perspective).  A minus sign indicates a multiple of the longest
  386. diagonal of the bounding box (plus 1%, for compatibility with 3dv).  The
  387. default is /d-3, identical to 3dv.
  388.  
  389. The output image is in 2D list format and, as already mentioned, can be
  390. directly displayed/plotted/printed with GNUPLOT, or converted to other
  391. formats.  The data is scaled is such a way that the image fits into a
  392. square with corners (-1,-1) and (1,1), with the object bounding box centre
  393. mapped into (0,0).  Some information is included in two lines of comments
  394. at the beginning of the file, like this:
  395.  
  396. # n=438 scale=43955.7 x_range=[-0.589757:0.432624] y_range=[-1:0.97761]
  397. # latitude=33.3 longitude=-60 distance=367590
  398.  
  399. In this example 438 is the number of points in the file, and 43955.7 is the
  400. scale factor that would restore the original object dimensions.  As
  401. mentioned before, x_range and y_range gives the extent of the image along
  402. the x and y axes, and may be used by 2DtoHPGL.  The second line contains
  403. the transformation details, with the viewpoint distance in absolute user
  404. units.
  405.  
  406. Hints for using GNUPLOT.  For best results you need to adjust the aspect
  407. ratio to 1:1 with the "set size" command.  With my monitor and Trident 8900
  408. card, I found by trial-and-error that "set size 0.82,1" and "set size
  409. 0.83,1" worked well for the standard VGA and for the SVGA 1024x768 modes,
  410. respectively.  For the HP DeskJet printer at 150 dpi, "set size 1.09,1" was
  411. best.  See the file "3D" for the GNUPLOT commands that you might need to
  412. use.  Better, edit that file if necessary, and display your 2D list by
  413. entering "GNUPLOT", followed by "LOAD '3D'".  The file "DJ" is an example
  414. for printer output on the DeskJet.  After displaying with 3D, you could
  415. enter "LOAD 'DJ'", and "REPLOT".
  416.  
  417. An interesting use of 3DVto2D would be for producing stereograms (stereo
  418. pairs or anaglyphs).  Just make two views with latitude zero and slightly
  419. different longitudes.  A difference of 4 to 7 degrees is generally
  420. recommended.  Exactly how to go about it for display/hardcopy/viewing is
  421. left as an exercise for the reader.
  422.  
  423. Answers to some Frequently Asked Questions:
  424.  
  425. The computations in 3dv are essentially as in 3DVto2D, but using integer
  426. arithmetic for speed.  The trick is to scale the values appropriately at
  427. the right places by factors high enough to maintain precision, but not as
  428. high as to overflow the 16-bit integers.  Easier said that done, but not
  429. that difficult, really. The precision achieved was better than the 256x192
  430. resolution of my home-made graphics card for the TRS-80 in the original
  431. implementation.  It is somewhat lower than EGA/VGA, though, and you may
  432. notice that sometimes points jump around a bit.  If you want to be elitist,
  433. the 32-bit integers on 386 processors would be more than enough.  And NO!,
  434. I am not releasing the source of 3dv, it is too ugly.
  435.  
  436. My original source for 3-D transformations was probably
  437.  
  438.     Ahuja, D.V., and Coons, S.A. "Geometry for construction and
  439.     display".  IBM Systems Journal 7,188-205. 1968.
  440.  
  441. (showing my age again!).  This is pretty good and still interesting,
  442. especially the use and explanation of homogeneous coordinates.  Nowadays
  443. you can probably find these things in most Computer Graphics textbooks. 
  444. Here goes a list, together with a somewhat concise (!) explanation, from
  445. the "Frequently Asked Questions" file in the Internet/USENET comp.graphics
  446. Newsgroup:
  447.  
  448.    1) General references for graphics questions:
  449.  
  450.     Computer Graphics: Principles and Practice (2nd Ed.), J.D. Foley,
  451.       A. van Dam, S.K. Feiner, J.F. Hughes, Addison-Wesley 1990, ISBN
  452.       0-201-12110-7
  453.     Principles of Interactive Computer Graphics (2nd Ed.), Newman and
  454.       Sproull, McGraw Hill, ISBN 0-07-046338-7
  455.     Procedural Elements for Computer Graphics, David F. Rogers, McGraw
  456.       Hill, ISBN 0-07-053534-5
  457.     Mathematical Elements for Computer Graphics 2nd Ed., David F. Rogers
  458.       and J. Alan Adams, McGraw Hill, ISBN 0-07-053530-2
  459.     Applied Concepts in Microcomputer Graphics, Bruce Artwick, Prentice-Hall,
  460.       ISBN 0-13-039322-3
  461.     Digital Picture Processing, vols. 1&2, Azriel Rosenfeld and Avi Kak,
  462.       Academic Press 1976
  463.     Three Dimensional Computer Graphics, Alan Watt, Addison-Wesley, ISBN
  464.       0-201-15442-0
  465.     An Introduction to Ray Tracing, Andrew Glassner (ed.), Academic Press
  466.       1989, ISBN 0-12-286160-4
  467.     Graphics Gems, Andrew Glassner (ed.), Academic Press 1990, ISBN
  468.       0-12-286165-5
  469.     Graphics Gems II, James Arvo (ed.), Academic Press 1991, ISBN
  470.       0-12-64480-0
  471.  
  472.    2) Drawing three-dimensional objects on a two-dimensional screen.  The
  473.    simple answer is, you divide by the depth.  For a more verbose
  474.    explanation, see any of the above references.
  475.  
  476. Well... that's all I know!
  477.  
  478.  
  479.                   2DtoHPGL
  480.  
  481. Syntax:  2DtoHPGL [/s] [/xn] [/yn] [/wn] [/hn] [/pn] [infile [outfile]]
  482.  
  483. Converts a 2D list to HPGL (Hewlett Packard Graphics Language) plotter
  484. instructions.  HPGL (alias IBM-GL, RD-GL, etc.) is used by many plotters,
  485. and is emulated on printers such as our IBM 4029 laser.  The PCL5 language
  486. used by the latest HP printers includes HPGL as a subset.  There are also
  487. software HPGL emulators for other devices, discussed below.
  488.  
  489. If the /s option is not specified, x_range and y_range information is
  490. expected in the file and used to scale the drawing up to the limits of the
  491. plotting area (with the HPGL IP and SC instructions).  If /s is given, it
  492. is assumed that the data fits into a square bounded by -1 and +1 (see
  493. 3DVto2D, above), and the scaling fits this square to the plotting area
  494. (useful for making stereograms, for example).  In both cases the
  495. aspect-ratio is preserved.
  496.  
  497. The /x and /y options can be used to specify the x and y coordinates of the
  498. centre of the plotting area, in plotter units.  On most (all?) plotters a
  499. plotter unit is 25 microns (40 units/mm).  The default /x5450 and /y3825
  500. corresponds to the centre of an A4 sheet (ISO standard, used in civilized
  501. countries).  For centring on US size A (letter) paper use /x5150.  The
  502. maximum size of the plotting area can be given with /w (width) and /h
  503. (height).  The defaults /w10000 and /h7200 will normally use most of the
  504. available space with both types of paper. More specifically, on the HP
  505. small plotters x goes from 0 to 10300 with size A paper, and to 10900 with
  506. A4, while y goes from 0 to 7650 with both.
  507.  
  508. A string of up to 15 digits can be given with the /p option to change the
  509. mapping from colour indices to pen numbers.  The default is
  510. /p123456781234567.
  511.  
  512. Only very basic HPGL instructions are used: DF (defaults), IP (input
  513. scaling points), SC (scale), SP (select pen), PU (move with pen up), and PD
  514. (draw with pen down).  Therefore, compatibility problems should be unlikely
  515. (really!).
  516.  
  517. Apart from plotters and laser printers, there is a number of HPGL
  518. emulators.  PRINTGL (shareware, US$40, <MSDOS.PLOT>PRTGL118.ZIP in
  519. SIMTEL20) is excellent, working with all sort of graphic cards and printers
  520. (it can also produce PCX raster files).  See DJPLOT.BAT for an example of
  521. coaxing the PaintJet driver in PRINTGL to print on the DeskJet 500C colour
  522. printer (with A4 paper).  Yes, I know, it looks horribly complicated; don't
  523. worry, PRINTGL has also an easy-to-use menu driven front end.  A similar
  524. program is SPLOT ("nagware", US$70, <MSDOS.GRAPHICS>SPLT244.ZIP), which can
  525. also convert to AutoCAD DXF format.  HPGL2PS (<MSDOS.POSTSCRIPT>HPGL2PS.ZIP)
  526. produces output for Postscript printers, is free, and includes C source. 
  527. Also free and with source included is <MSDOS.AUTOCAD>HPGL2SCR.ZIP, a
  528. program to convert HPGL to AutoCAD DXF.
  529.  
  530. Two free HPGL pre-viewers (screen output only), including source code, are
  531. found in SIMTEL in <MSDOS.GRAPHICS>SHOWGL15.ZIP (written in C), and
  532. <MSDOS.GRAPHICS>HPGLVU10.ZIP (Pascal).  Unfortunately, no free HPGL to
  533. (non-Postscript) printer output seems to be available.  It would not be too
  534. difficult, though, to modify the SHOWGL, HPGLVU, or HPGL2PS code, perhaps
  535. using the BGI printer drivers in <MSDOS.BORLAND>PRBGI094.ZIP (Hint! Hint!).
  536. Another alternative would be to use HPGL2PS together with the Ghostscript
  537. Postscript emulator (available in the SIMTEL <MSDOS.POSTSCRIPT> directory).
  538.  
  539.  
  540.                   2DtoEXF
  541.  
  542. Syntax:  2DtoEXF [infile [outfile]]
  543.  
  544. EasyCAD is a neat little CAD program, produced by Evolution Computing, that
  545. used to come bundled with the MicroSoft mouse.  BTW, I believe in "small is
  546. beautiful", and dislike monsters such as AutoCAD, Mathematica (use DERIVE
  547. instead!), and MS Windows.  Anyway, EasyCAD has a CONVERT utility that can
  548. convert EasyCAD's binary .DWG files to and from ASCII .EXF (Exchange File
  549. Format) files (and also to and from AutoCAD .DXF files).  2DtoEXF converts
  550. 2D lists into .EXF files.  I believe that Evolution computing also makes
  551. another system called FastCAD, that presumably also accepts EXF.
  552.  
  553. 2DtoEXF does not use any of the information (x_range, etc) in the initial
  554. comment lines of the 2D file.  After converting to .DWG, you can use
  555. EasyCAD for editing (e.g. adding text, erasing hidden lines, etc.), and/or
  556. plotting/printing.  See the description of 2DtoHPGL above for conversion to
  557. AutoCAD or other systems accepting DXF.
  558.  
  559.  
  560.                  LEGAL TRIVIA, ETC.
  561.                  ------------------
  562.  
  563. You can do whatever you like with all this (just like that!).  I thought
  564. hard about placing copyright notices everywhere, having read horror stories
  565. about people stealing public domain software and restricting its use by
  566. others.  Finally decided against it, for no good reason, really.  I just
  567. did not feel like adding to what is hopefully no more than generalized
  568. paranoia.  If I am wrong, the world will just have to learn to survive
  569. without these earth-shattering pieces of software.  Anyway, if you get rich
  570. with this without giving me my part of the booty I wish you burn in Hell,
  571. your yacht sinks, and the IRS investigates you.
  572.  
  573. I also gather that, because of a lawyers infestation somewhere, I am
  574. supposed to say things like that I am completely irresponsible (a well
  575. known fact), that this software is not guaranteed to improve your sex life
  576. (or your money back), that IBM is a registered trademark of IBM, etc. 
  577. Whatever.  Lawyers: I am a fair distance away, and I have no money (er...
  578. umm... don't take it as a challenge, guys!).
  579.  
  580. After writing this, Keith Petersen asked me that if I include here the
  581. SIMTEL.DOC file "Please make it clear that SIMTEL20 has no connection with
  582. your product and does not endorse it" (see what I mean?).  SIMTEL20 HAS NO
  583. CONNECTION WITH MY PRODUCT, AND DOES NOT ENDORSE IT  :-) .
  584.  
  585. By the way, my employer had nothing to do with this either.  Here goes my
  586. home address until August 1992 or so.  I am moving but I don't know where
  587. yet.  My e-mail address will probably change sooner than that, and I may
  588. temporarily lose Internet access at any moment.
  589.  
  590. Oscar García
  591. 1 Clyde Street
  592. Rotorua
  593. New Zealand              Internet: garciao@mof.govt.nz
  594.  
  595.